package com.ztools.utils;

import android.text.TextUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 对数子进行校验
 *
 * Created by zhangxuehui on 2018/6/6.
 */
public class NumberUtils {


    /**
     * 字符串是否为数字
     *
     * @param str
     * @return
     */
    public static boolean isNumber(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        Pattern pattern = Pattern.compile("^-?\\+?[0-9]+(.[0-9]+)?%?$");
        Matcher isNum = pattern.matcher(str);
        boolean bl = isNum.matches();
        return bl;
    }
}
